<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    *{
      margin: 0;
      padding: 0;
    }
    main{
      width: 100vw;
      height: 100vh;
      background-color: cyan;
      animation-name: rotate;
      animation-duration: 2s;
      /*  动画循环的次数,  */
      /* animation-iteration-count:infinite; */
      animation-fill-mode: forwards;
      display: flex;
      justify-content: center;
      align-items: center;
      flex-direction: column;
    }
    main::after{
      content: 'hello ck';
      animation-name: opacity;
      animation-duration: 2s;
      animation-delay: 2s;
      opacity: 0;
      font-size: 2rem;
      animation-fill-mode: forwards;
    }
    nav{
      height: 5rem;
      width: 100vw;
      background-color: purple;
      animation-name: animation, opacity;
      animation-delay: 2s;
      animation-duration: 2s;
      align-self: flex-start;
      justify-self: self-start;
      animation-fill-mode: forwards;
      margin-left: 0;
      opacity: 0;
      position:absolute;
      top: 0;
      left: 0;
      display: flex;
      justify-content: center;
      align-items: center;
    }
    nav::after{
      content: 'BMW';
      color: white;
      opacity: 0;
      animation-name: opacity;
      animation-duration: 2s;
      animation-delay: 4s;
      animation-fill-mode: forwards;
      font-size: 2rem;
    }
    @keyframes animation{
      from{
        margin-left: -100vw;
      }
      to{
        margin-left: 0;
      }
    }
    @keyframes opacity{
      from{
        opacity: 0;
      }
      to{
        opacity: 1;
      }
    }

    @keyframes rotate{
      from{
        transform: rotate(0);
        background-color: darkgreen;
      }
      to{
        transform: rotate(360deg);
      }
    }
  </style>
</head>
<body>
  <main>
    <nav></nav>
  </main>

<Script>
  window.onload = () => {
    const ONav = document.querySelector('nav')
    ONav.addEventListener('animationend', (e) => {
      e.stopPropagation()
      console.log('动画结束')
    })
  }
</Script>
</body>
</html>
